﻿Shader "Unlit/NewUnlitShader1"
{
	Properties
	{
		_MainTex ("Texture", 2D) = "white" {}

	//-------------------add----------------------
		  _MinX("Min X", Float) = -10
		  _MaxX("Max X", Float) = 10
		  _MinY("Min Y", Float) = -10
		  _MaxY("Max Y", Float) = 10
			  //-------------------add----------------------

			  //如果需要mask裁剪请复制下述代码 begin
			_StencilComp("Stencil Comparison", Float) = 8
			_Stencil("Stencil ID", Float) = 0
			_StencilOp("Stencil Operation", Float) = 0
			_StencilWriteMask("Stencil Write Mask", Float) = 255
			_StencilReadMask("Stencil Read Mask", Float) = 255

			_ColorMask("Color Mask", Float) = 15

			[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
			  //如果需要mask裁剪请复制上述代码 end
	}
	SubShader
	{
		Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
			//Blend SrcAlpha One
			  Blend SrcAlpha OneMinusSrcAlpha
			//AlphaTest Greater .01
			//ColorMask RGB
			//Cull Off Lighting Off ZWrite Off Fog { Color(0,0,0,0) }

		Pass
		{
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			// make fog work
			#pragma multi_compile_fog
			
			#include "UnityCG.cginc"
			#include "UnityUI.cginc"

			struct appdata
			{
				float4 vertex : POSITION;
				float2 uv : TEXCOORD0;
			};

			struct v2f
			{
				float2 uv : TEXCOORD0;
				UNITY_FOG_COORDS(1)
				float4 vertex : SV_POSITION;
				float4 worldPosition : TEXCOORD1;
			};

			float4 _ClipRect;
			sampler2D _MainTex;
			float4 _MainTex_ST;
		
			
			v2f vert (appdata v)
			{
				v2f o;
				o.vertex = UnityObjectToClipPos(v.vertex);
				o.uv = TRANSFORM_TEX(v.uv, _MainTex);
				UNITY_TRANSFER_FOG(o,o.vertex);
				o.worldPosition = v.vertex;
				return o;
			}
			
			fixed4 frag (v2f i) : SV_Target
			{
				fixed4 col = tex2D(_MainTex, i.uv);
				UNITY_APPLY_FOG(i.fogCoord, col);
				col.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
				return col;
			}
			ENDCG
		}
	}
}
